
class BaseModel {
  constructor(users) {
    this.users = users
  }
  all() {
    return this.users
  }
  first(uid) {
    return this.users.find(({ id }) => id == uid)
  }
  create(body) {
    return this.users.push(body)
  }
  update(uid, body) {
    let index = this.users.findIndex(({ id }) => id == uid)
    this.users[index] = { ...this.users[index], ...body }
  }
  destroy(uid) {
    this.users.filter(({ id }) => id != uid)
  }
}

module.exports = BaseModel